package com.google.utility;

import java.util.Date;

public class TimeMachine {

	private Date startTime;
	private String status = STOPPED;

	public TimeMachine() {
	}

	public void start() {
		startTime = DateUtil.getNow();
		status = RUNNING;
	}

	public long finish() {
		long period = 0;
		if (RUNNING.equals(status)) {
			Date endTime = DateUtil.getNow();
			period = endTime.getTime() - startTime.getTime();
			status = STOPPED;
		}
		return period;
	}

	final private static String RUNNING = "Running";
	final private static String STOPPED = "Stopped";

}
